﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Jinjia.Approve.IRepository;
using Jinjia.Approve.IRepository.JJFlow;
using Jinjia.Approve.IService.JJFlow.Approvers;
using SqlSugar.Extensions;

namespace Jinjia.Approve.Service.JJFlow.Approvers
{
    public class PurchaseApproverRealize : IJJApprovers
    {
        private readonly IJJApproversRepository _jjApproversRepository;
        private readonly IErpaBaseRepository _erpaBaseRepository;

        public PurchaseApproverRealize(IJJApproversRepository jjApproversRepository, IErpaBaseRepository erpaBaseRepository)
        {
            _jjApproversRepository = jjApproversRepository;
            _erpaBaseRepository = erpaBaseRepository;
        }

        public async Task<List<int>> GetInstanceNodeEmpInfo(string biz_order_id, int start_user = 0, string depart_id = "0", Dictionary<string, string> dic = null)
        {
            var leader_idlist = await _jjApproversRepository.PurchaseApproverRealizeGetLeaderIdList(biz_order_id);
            if (leader_idlist.Count == 0)
            {
                //获取采购战略品牌部第三几默认审批人
                var lead_id = await _erpaBaseRepository.GetValueByCodeType("PurchaseBrandApproveLeader");
                //如果品牌对应的负责人为空，则默认
                leader_idlist.Add(lead_id.ObjToInt());
            }

            return leader_idlist;
        }
    }
}